package com.atguigu.springcloud.alibaba.controller;

import com.atguigu.springcloud.alibaba.service.StorageService;
import com.atguigu.springcloud.entities.CommonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author: shikong
 * @Date: 2020/8/13 16:46
 */

@RestController
@Slf4j
public class StorageController {

    @Resource
    private StorageService storageService;

    @GetMapping("/storage/findAll")
    public CommonResult findAllStorage(){

        return new CommonResult(200,"successful",storageService.findAllStorage());
    }

    @PostMapping("/storage/update")
    public CommonResult storageUpdate(Long productId, Integer count){

        log.info("count{} ",count);
        storageService.storageUpdate(productId,count);
        return new CommonResult(200,"successful","库存扣减成功");
    }




}
